<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商铺信息编辑</title>
    {{template  "link/sell/link.html" .}}
</head>
<body>
<div  >
    <ul class="layui-nav">
        <li class="layui-nav-item"><a href="">店铺:{{.Store.StoresName}}</a></li>
        <li class="layui-nav-item "><a href="/sell/index">店铺主页</a></li>
        <li class="layui-nav-item"><a href="/sell/orderList">订单</a></li>
        <li class="layui-nav-item layui-this"><a href="/sell/store/manage">店铺管理</a></li>
        <li class="layui-nav-item"><a href="/sell/goodManage">商品管理</a></li>
        <li class="layui-nav-item"><a href="/sell/kindManage">种类管理</a></li>
        <li class="layui-nav-item"><a href="/sell/logout">退出</a></li>
    </ul>
</div>


<div class="layui-main">
    <div class="layui-row">
        <legend class="registerWord">商铺信息修改</legend>
    </div>
    <div class="layui-row">
        <div class="layui-col-lg-offset3 layui-col-lg6">
            <div class="register">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend>商铺名字</legend>
                    </fieldset>
                    <div class="layui-form-item">
                        <input type="text" class="layui-input" disabled="disabled" value="{{.Store.StoresName}}">
                    </div>
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend>商铺简介</legend>
                    </fieldset>

                    <div class="layui-form-item">
                        <textarea  id ="store-info" class="layui-textarea" name="" id="" cols="30" rows="10">{{.StoresDescription}}</textarea>
                    </div>
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend>商铺横幅</legend>
                    </fieldset>
                    <div class="layui-upload-drag" id="test10">
                        <i class="layui-icon"></i>
                        <p>点击上传，或将文件拖拽到此处</p>
                    </div>
                    <p id="mainPicMsg"></p>
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend>商铺轮播图片</legend>
                    </fieldset>
                    <button class="layui-btn demoMore" lay-data="{url: '/sell/store/upload/loopPic1'}">上传图片1</button>
                    <button class="layui-btn demoMore" lay-data="{url: '/sell/store/upload/loopPic2'}">上传图片2</button>
                    <button class="layui-btn demoMore" lay-data="{url: '/sell/store/upload/loopPic3'}">上传图片3</button>
            </div>
        </div>
    </div>
</div>
{{template  "link/sell/footer.html" .}}

<script src="/static/js/citys.js"></script>
<script>

    layui.use(['jquery', 'layer', 'form', 'table', 'upload'], function (args) {
        var table = layui.table;
        table.render({
            elem: '#test'
            , cols: [[
                {
                    field: 'id', width: 100, title: 'ID', sort: true
                }
                ,
                {
                    field: 'username', width: 150, title: '用户名'
                }
                ,
                {
                    field: 'price', width: 80, title: 'price'
                }
                ,
                {
                    field: 'addFile', title: '设置热门', templet: function (d) {
                        return '<input type="checkbox" name="isHot" titile="热门" ' + ' value= ' + d.id + '  lay-skin="switch" lay-text="是|否" >'
                    }
                },

            ]]
            , data: [{
                "id": "123",
                "username": "jack",
                "price": 123
            }]
            , page: true
        });
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
        var $ = layui.jquery
            , upload = layui.upload;
        //拖拽上传
        upload.render(
            {
                elem: '#test10'
                , url: '/sell/store/upload/mainPic'
                , accpet:'images'
                , done: function (res) {
                    $("#mainPicMsg").html("上传完成")
                }
                ,error:function (res) {
                    $("mainPicMsg").html("上传失败")
                }
            }
        );


        $("#store-info").blur(function () {
            $.ajax({
                type: 'POST',
                url: '/sell/store/storeInfo',
                data: {
                    storeinfo:$("#store-info").val()
                },
                success: function () {
                    console.log('ok')
                },
                dataType: 'json'
            });
        })

        //同时绑定多个元素，并将属性设定在元素上
        upload.render({
            elem: '.demoMore'
            ,before: function(){
                layer.tips('上传中：', this.item, {tips: 1});
            }
            ,done: function(res, index, upload){
                var item = this.item;
                layer.tip('上传成功',this.item,{tips:1})
            }
        })
        
        setHot:function setHost(data) {

        }

    });

</script>
</body>
</html>